package com.qianhui.action;

import com.qianhui.bean.Page;
import com.qianhui.common.*;
import com.qianhui.dao.OrderGoodsDAO;
import com.qianhui.orderapi.ODAPI;
import com.qianhui.pojo.*;
import com.qianhui.view.*;
import net.sf.json.JSONArray;
import weixin.popular.api.QrcodeAPI;
import weixin.popular.bean.qrcode.QrcodeTicket;
import weixin.popular.support.TokenManager;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;

public class ManagerAction extends BaseAction
{

    // 常用变量
    private Map<String, Object> json;// 返回到前台的map对象
    private Manager manager;
    private List<Manager> managerList;
    private List<ManagerView> managerViewList;
    private String goodsTypeJson;

    private Page page;
    private Goods goods;
    private Order order;

    private Coupon coupon;
    private List<Coupon> couponList;
    private Article article;
    private List<Article> articleList;
    private List<BuyerMessage> buyerMessageList;
    private BuyerMessage buyerMessage;
    private List<BuyerMessageView> buyerMessageViewList;

    private Buyer buyer;
    private List<Buyer> buyerList;
    private GoodsCommission goodsCommission;
    private List<GoodsCommission> goodsCommissionList;
    private List<GoodsCommissionView> goodsCommissionViewList;

    private Kefu kefu;
    private List<KefuView> kefuViewList;
    private Advertisement advertisement;
    private List<Advertisement> advertisementList;

    private List<ComplexOrder> complexOrderList;
    private String commonStr;
    private GoodsHistory goodsHistory;
    private Comment comment;
    private Shop shop;
    private OrderReturn orderReturn;
    private List<OrderReturn> orderReturnList;
    private List<ComplexOrderReturn> complexOrderReturnList;

    Map<String, GoodsType> goodsTypeMap;
    private List<Goods> goodsList;
    private OrderDeclaration orderDeclaration;

    private List<ProvincePostage> provincePostageList;

    private ManagerModule managerModule;
    private List<ManagerModule> managerModuleList;

    private File excelFile; // 具体上传文件的 引用 , 指向临时目录中的临时文件
    private String excelFileFileName; // 上传文件的名字 ,FileName 固定的写法
    private String excelFileContentType; // 上传文件的类型， ContentType 固定的写法

    public ManagerAction()
    {
        json = new HashMap<String, Object>();
    }

    public String m_login_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }
        if (CM.validIsEmpty(manager.getManagerName()) || CM.validIsEmpty(manager.getManagerPassword()))
        {
            info = "用户名、密码都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Manager managerFromDB = managerDAO.findByManagerNameAndManagerPassword(getManager().getManagerName(), getManager().getManagerPassword());

        if (managerFromDB == null)
        {
            info = "用户名或密码错误。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        getSession().setAttribute("managerSession", managerFromDB);
        json.put("success", true);
        return SUCCESS;
    }

    public String exit()
    {
        getSession().removeAttribute("managerSession");
        return SUCCESS;
    }

    public String update_custom_type()
    {
        List<GoodsType> goodsTypeListTemp = goodsTypeDAO.findAll();
        if (goodsTypeListTemp.size() == 0)
        {
            setGoodsTypeJson(null);
        }
        Map<String, GoodsTypeView> goodsTypeMap = new LinkedHashMap<String, GoodsTypeView>();
        for (GoodsType gt : goodsTypeListTemp)
        {
            // System.out.println(gt.toString());
            GoodsTypeView gtvTemp = new GoodsTypeView();
            gtvTemp.setId(gt.getGoodsTypeId());
            gtvTemp.setName(gt.getGoodsTypeName());
            gtvTemp.setpId(gt.getGoodsTypeParentId() == null ? "" : gt.getGoodsTypeParentId());
            gtvTemp.setOpen(false);
            gtvTemp.setNoR(false);
            gtvTemp.setGrade(1);
            goodsTypeMap.put(gt.getGoodsTypeId(), gtvTemp);
        }
        List<GoodsTypeView> goodsTypeViewListForJson = new ArrayList<GoodsTypeView>();
        Set<Map.Entry<String, GoodsTypeView>> set = goodsTypeMap.entrySet();
        for (Iterator<Map.Entry<String, GoodsTypeView>> it = set.iterator(); it.hasNext(); )
        {
            Map.Entry<String, GoodsTypeView> entry = (Map.Entry<String, GoodsTypeView>) it.next();
            // System.out.println(entry.getKey() + "--->" + entry.getValue());
            if (CM.validIsEmpty(entry.getValue().getpId()))
            {
                entry.getValue().setGrade(1);
                entry.getValue().setOpen(true);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            else if (CM.validIsEmpty(goodsTypeMap.get(entry.getValue().getpId()).getpId()))
            {
                entry.getValue().setGrade(2);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            else if (CM.validIsEmpty(goodsTypeMap.get(goodsTypeMap.get(entry.getValue().getpId()).getpId()).getpId()))
            {
                entry.getValue().setGrade(3);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            goodsTypeViewListForJson.add(entry.getValue());
        }

        JSONArray jsonArray = JSONArray.fromObject(goodsTypeViewListForJson);
        setGoodsTypeJson(jsonArray.toString());

        return SUCCESS;
    }

    public String show_shop()
    {
        return SUCCESS;
    }

    public String shop_add_goods()
    {
        List<GoodsType> goodsTypeListTemp = goodsTypeDAO.findAll();
        if (goodsTypeListTemp.size() == 0)
        {
            setGoodsTypeJson(null);
        }
        Map<String, GoodsTypeView> goodsTypeMap = new LinkedHashMap<String, GoodsTypeView>();
        for (GoodsType gt : goodsTypeListTemp)
        {
            // System.out.println(gt.toString());
            GoodsTypeView gtvTemp = new GoodsTypeView();
            gtvTemp.setId(gt.getGoodsTypeId());
            gtvTemp.setName(gt.getGoodsTypeName());
            gtvTemp.setpId(gt.getGoodsTypeParentId() == null ? "" : gt.getGoodsTypeParentId());
            gtvTemp.setOpen(false);
            gtvTemp.setNoR(false);
            gtvTemp.setGrade(1);
            goodsTypeMap.put(gt.getGoodsTypeId(), gtvTemp);
        }
        List<GoodsTypeView> goodsTypeViewListForJson = new ArrayList<GoodsTypeView>();
        Set<Map.Entry<String, GoodsTypeView>> set = goodsTypeMap.entrySet();
        for (Iterator<Map.Entry<String, GoodsTypeView>> it = set.iterator(); it.hasNext(); )
        {
            Map.Entry<String, GoodsTypeView> entry = (Map.Entry<String, GoodsTypeView>) it.next();
            // System.out.println(entry.getKey() + "--->" + entry.getValue());
            if (CM.validIsEmpty(entry.getValue().getpId()))
            {
                entry.getValue().setGrade(1);
                entry.getValue().setOpen(true);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            else if (CM.validIsEmpty(goodsTypeMap.get(entry.getValue().getpId()).getpId()))
            {
                entry.getValue().setGrade(2);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            else if (CM.validIsEmpty(goodsTypeMap.get(goodsTypeMap.get(entry.getValue().getpId()).getpId()).getpId()))
            {
                entry.getValue().setGrade(3);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            goodsTypeViewListForJson.add(entry.getValue());
        }

        JSONArray jsonArray = JSONArray.fromObject(goodsTypeViewListForJson);
        setGoodsTypeJson(jsonArray.toString());

        return SUCCESS;
    }

    public String m_add_goods_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getGoods() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getGoods().getGoodsName());
        validStrList.add(getGoods().getGoodsTypeId());
        validStrList.add(getGoods().getGoodsMainPic());
        validStrList.add(getGoods().getGoodsGallery());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        if (getGoods().getGoodsOriginalPrice() != null && getGoods().getGoodsOriginalPrice() <= getGoods().getGoodsPrice())
        {
            info = "如果填写商品原价格则必须要大于商品现价格。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<String> goodsMainPic_pictureListTemp = CM.getImgSrcList(getGoods().getGoodsMainPic(), 1);
        List<String> goodsGallery_pictureListTemp = CM.getImgSrcList(getGoods().getGoodsGallery(), 5);
        if (goodsMainPic_pictureListTemp == null || goodsGallery_pictureListTemp == null)
        {
            info = "照片上传是必选项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        getGoods().setGoodsMainPic(goodsMainPic_pictureListTemp.get(0));
        getGoods().setGoodsGallery(CM.fromPictureSrcListToOneListStr(goodsGallery_pictureListTemp));
        getGoods().setGoodsId(CM.getRandomTwentyFivePrimaryKeyId());
        getGoods().setGoodsStatus("准备中");
        Timestamp timestampTemp = new Timestamp(Calendar.getInstance().getTimeInMillis());
        getGoods().setGoodsStartTime(timestampTemp);
        getGoods().setGoodsUpdateTime(timestampTemp);

        getGoods().setGoodsSalesNumber(0);
        getGoods().setGoodsCommentNumber(0);

        Goods goodsResult = goodsDAO.save(getGoods());
        if (goodsResult == null)
        {
            info = "商品保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String show_goods_info_list()
    {
        // 得到商品类型
        List<GoodsType> goodsTypeListTemp = goodsTypeDAO.findAll();
        if (goodsTypeListTemp.size() == 0)
        {
            setGoodsTypeJson(null);
        }
        Map<String, GoodsTypeView> goodsTypeMap = new LinkedHashMap<String, GoodsTypeView>();
        for (GoodsType gt : goodsTypeListTemp)
        {
            // System.out.println(gt.toString());
            GoodsTypeView gtvTemp = new GoodsTypeView();
            gtvTemp.setId(gt.getGoodsTypeId());
            gtvTemp.setName(gt.getGoodsTypeName());
            gtvTemp.setpId(gt.getGoodsTypeParentId() == null ? "" : gt.getGoodsTypeParentId());
            gtvTemp.setOpen(false);
            gtvTemp.setNoR(true);
            gtvTemp.setGrade(1);
            goodsTypeMap.put(gt.getGoodsTypeId(), gtvTemp);
        }
        List<GoodsTypeView> goodsTypeViewListForJson = new ArrayList<GoodsTypeView>();
        Set<Map.Entry<String, GoodsTypeView>> set = goodsTypeMap.entrySet();
        for (Iterator<Map.Entry<String, GoodsTypeView>> it = set.iterator(); it.hasNext(); )
        {
            Map.Entry<String, GoodsTypeView> entry = (Map.Entry<String, GoodsTypeView>) it.next();
            // System.out.println(entry.getKey() + "--->" + entry.getValue());
            if (CM.validIsEmpty(entry.getValue().getpId()))
            {
                entry.getValue().setGrade(1);
                entry.getValue().setOpen(true);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            else if (CM.validIsEmpty(goodsTypeMap.get(entry.getValue().getpId()).getpId()))
            {
                entry.getValue().setGrade(2);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            else if (CM.validIsEmpty(goodsTypeMap.get(goodsTypeMap.get(entry.getValue().getpId()).getpId()).getpId()))
            {
                entry.getValue().setGrade(3);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            goodsTypeViewListForJson.add(entry.getValue());
        }

        JSONArray jsonArray = JSONArray.fromObject(goodsTypeViewListForJson);
        setGoodsTypeJson(jsonArray.toString());

        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        Map<String, GoodsType> goodsTypeMapTemp = new HashMap<String, GoodsType>();
        if (goodsTypeMapTemp != null)
        {
            for (GoodsType gtTemp : goodsTypeListTemp)
            {
                goodsTypeMapTemp.put(gtTemp.getGoodsTypeId(), gtTemp);
            }
        }
        setGoodsTypeMap(goodsTypeMapTemp);

        String status = getRequest().getParameter("s");
        String tid = getRequest().getParameter("tid");
        String keyword = getRequest().getParameter("k");
        int onePageSize = 20;
        List<Goods> resList = null;
        int countTemp = 0;
        resList = goodsDAO.getListByIndexAndPageSizeAndStatusAnd_tidAnd_keyword(index, onePageSize, status, tid, keyword);
        countTemp = goodsDAO.getGoodsTotalCountByStatusAnd_tidAnd_keyword(status, tid, keyword);
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        setGoodsList(resList);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String show_goods_detail()
    {
        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            return "404";
        }
        Goods goodsTemp = goodsDAO.findById(getCommonStr());
        goodsTemp.setGoodsMainPic(CM.fromSomePictureSrcToImgTagString(goodsTemp.getGoodsMainPic()));
        goodsTemp.setGoodsGallery(CM.fromSomePictureSrcToImgTagString(goodsTemp.getGoodsGallery()));
        setGoods(goodsTemp);
        return SUCCESS;
    }

    public String show_order_declaration_detail()
    {
        String id_pass = getRequest().getParameter("id");
        if (CM.validIsEmpty(id_pass))
        {
            return "404";
        }

        OrderDeclaration orderDeclarationTemp = orderDeclarationDAO.findByOrderId(id_pass);
        setOrderDeclaration(orderDeclarationTemp);
        return SUCCESS;
    }

    public String show_goods_snapshot()
    {
        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            return "404";
        }
        GoodsHistory goodsHistoryTemp = goodsHistoryDAO.findById(getCommonStr());
        goodsHistoryTemp.setGoodsMainPic(CM.fromSomePictureSrcToImgTagString(goodsHistoryTemp.getGoodsMainPic()));
        goodsHistoryTemp.setGoodsGallery(CM.fromSomePictureSrcToImgTagString(goodsHistoryTemp.getGoodsGallery()));
        setGoodsHistory(goodsHistoryTemp);
        return SUCCESS;
    }

    public String shop_update_goods()
    {
        List<GoodsType> goodsTypeListTemp = goodsTypeDAO.findAll();
        if (goodsTypeListTemp.size() == 0)
        {
            setGoodsTypeJson(null);
        }
        Map<String, GoodsTypeView> goodsTypeMap = new LinkedHashMap<String, GoodsTypeView>();
        for (GoodsType gt : goodsTypeListTemp)
        {
            // System.out.println(gt.toString());
            GoodsTypeView gtvTemp = new GoodsTypeView();
            gtvTemp.setId(gt.getGoodsTypeId());
            gtvTemp.setName(gt.getGoodsTypeName());
            gtvTemp.setpId(gt.getGoodsTypeParentId() == null ? "" : gt.getGoodsTypeParentId());
            gtvTemp.setOpen(false);
            gtvTemp.setNoR(false);
            gtvTemp.setGrade(1);
            goodsTypeMap.put(gt.getGoodsTypeId(), gtvTemp);
        }
        List<GoodsTypeView> goodsTypeViewListForJson = new ArrayList<GoodsTypeView>();
        Set<Map.Entry<String, GoodsTypeView>> set = goodsTypeMap.entrySet();
        for (Iterator<Map.Entry<String, GoodsTypeView>> it = set.iterator(); it.hasNext(); )
        {
            Map.Entry<String, GoodsTypeView> entry = (Map.Entry<String, GoodsTypeView>) it.next();
            // System.out.println(entry.getKey() + "--->" + entry.getValue());
            if (CM.validIsEmpty(entry.getValue().getpId()))
            {
                entry.getValue().setGrade(1);
                entry.getValue().setOpen(true);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            else if (CM.validIsEmpty(goodsTypeMap.get(entry.getValue().getpId()).getpId()))
            {
                entry.getValue().setGrade(2);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            else if (CM.validIsEmpty(goodsTypeMap.get(goodsTypeMap.get(entry.getValue().getpId()).getpId()).getpId()))
            {
                entry.getValue().setGrade(3);
                goodsTypeMap.put(entry.getKey(), entry.getValue());
            }
            goodsTypeViewListForJson.add(entry.getValue());
        }

        JSONArray jsonArray = JSONArray.fromObject(goodsTypeViewListForJson);
        setGoodsTypeJson(jsonArray.toString());
        // 得到此商品的信息
        String goods_id_str = getRequest().getParameter("id");
        if (goods_id_str == null || CM.validIsEmpty(goods_id_str))
        {
            return ERROR;
        }
        Goods goodsTemp = goodsDAO.findById(goods_id_str);
        goodsTemp.setGoodsMainPic(CM.fromSomePictureSrcToImgTagString(goodsTemp.getGoodsMainPic()));
        goodsTemp.setGoodsGallery(CM.fromSomePictureSrcToImgTagString(goodsTemp.getGoodsGallery()));
        setGoods(goodsTemp);

        return SUCCESS;
    }

    public String m_update_goods_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getGoods() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getGoods().getGoodsId());
        validStrList.add(getGoods().getGoodsName());
        validStrList.add(getGoods().getGoodsTypeId());
        validStrList.add(getGoods().getGoodsMainPic());
        validStrList.add(getGoods().getGoodsGallery());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        if (getGoods().getGoodsOriginalPrice() != null && getGoods().getGoodsOriginalPrice() <= getGoods().getGoodsPrice())
        {
            info = "如果填写商品原价格则必须要大于商品现价格。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<String> goodsMainPic_pictureListTemp = CM.getImgSrcList(getGoods().getGoodsMainPic(), 1);
        List<String> goodsGallery_pictureListTemp = CM.getImgSrcList(getGoods().getGoodsGallery(), 5);
        if (goodsMainPic_pictureListTemp == null || goodsGallery_pictureListTemp == null)
        {
            info = "照片上传是必选项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        getGoods().setGoodsMainPic(CM.fromPictureSrcListToOneListStr(goodsMainPic_pictureListTemp));
        getGoods().setGoodsGallery(CM.fromPictureSrcListToOneListStr(goodsGallery_pictureListTemp));

        Goods goodsFromDB = goodsDAO.findById(getGoods().getGoodsId());
        if (goodsFromDB == null)
        {
            info = "没有找到此商品。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        goodsFromDB.setGoodsName(getGoods().getGoodsName());
        goodsFromDB.setGoodsTips(getGoods().getGoodsTips());
        goodsFromDB.setGoodsBrand(getGoods().getGoodsBrand());
        goodsFromDB.setGoodsItemId(getGoods().getGoodsItemId());

        goodsFromDB.setGoodsHscode(getGoods().getGoodsHscode());
        goodsFromDB.setGoodsCiqGoodsNo(getGoods().getGoodsCiqGoodsNo());
        goodsFromDB.setGoodsCustomsListNo(getGoods().getGoodsCustomsListNo());

        goodsFromDB.setGoodsPrice(getGoods().getGoodsPrice());
        goodsFromDB.setGoodsOriginalPrice(getGoods().getGoodsOriginalPrice());
        goodsFromDB.setGoodsMinBuyNumber(getGoods().getGoodsMinBuyNumber());
        goodsFromDB.setGoodsInventoryNumber(getGoods().getGoodsInventoryNumber());
        goodsFromDB.setGoodsCommission(getGoods().getGoodsCommission());
        goodsFromDB.setGoodsDiscount(getGoods().getGoodsDiscount());

        goodsFromDB.setGoodsMainPic(getGoods().getGoodsMainPic());
        goodsFromDB.setGoodsGallery(getGoods().getGoodsGallery());

        goodsFromDB.setGoodsDetail(getGoods().getGoodsDetail());
        goodsFromDB.setGoodsTypeId(getGoods().getGoodsTypeId());
        goodsFromDB.setGoodsOperationMode(getGoods().getGoodsOperationMode());

        goodsFromDB.setGoodsPostageType(getGoods().getGoodsPostageType());

        Timestamp timestampTemp = new Timestamp(Calendar.getInstance().getTimeInMillis());
        goodsFromDB.setGoodsUpdateTime(timestampTemp);

        List<GoodsHistory> goodsHistoryListTemp = new ArrayList<GoodsHistory>();
        if (goodsFromDB.getGoodsStatus().equals("销售中"))
        {
            GoodsHistory goodsHistoryTemp = new GoodsHistory();

            goodsHistoryTemp.setHistoryId(CM.getRandomTwentyFivePrimaryKeyId());
            goodsHistoryTemp.setGoodsId(goodsFromDB.getGoodsId());
            goodsHistoryTemp.setGoodsName(goodsFromDB.getGoodsName());
            goodsHistoryTemp.setGoodsTips(goodsFromDB.getGoodsTips());
            goodsHistoryTemp.setGoodsBrand(goodsFromDB.getGoodsBrand());
            goodsHistoryTemp.setGoodsItemId(goodsFromDB.getGoodsItemId());
            goodsHistoryTemp.setGoodsPrice(goodsFromDB.getGoodsPrice());
            goodsHistoryTemp.setGoodsOriginalPrice(goodsFromDB.getGoodsOriginalPrice());
            goodsHistoryTemp.setGoodsMinBuyNumber(goodsFromDB.getGoodsMinBuyNumber());
            goodsHistoryTemp.setGoodsInventoryNumber(goodsFromDB.getGoodsInventoryNumber());
            goodsHistoryTemp.setGoodsSalesNumber(goodsFromDB.getGoodsSalesNumber());
            goodsHistoryTemp.setGoodsCommentNumber(goodsFromDB.getGoodsCommentNumber());
            goodsHistoryTemp.setGoodsStartTime(goodsFromDB.getGoodsStartTime());
            goodsHistoryTemp.setGoodsCommission(goodsFromDB.getGoodsCommission());
            goodsHistoryTemp.setGoodsDiscount(goodsFromDB.getGoodsDiscount());
            goodsHistoryTemp.setGoodsMainPic(goodsFromDB.getGoodsMainPic());
            goodsHistoryTemp.setGoodsGallery(goodsFromDB.getGoodsGallery());
            goodsHistoryTemp.setGoodsDetail(goodsFromDB.getGoodsDetail());
            goodsHistoryTemp.setGoodsTypeId(goodsFromDB.getGoodsTypeId());
            goodsHistoryTemp.setGoodsOperationMode(goodsFromDB.getGoodsOperationMode());
            goodsHistoryTemp.setGoodsStatus(goodsFromDB.getGoodsStatus());
            goodsHistoryTemp.setGoodsUpdateTime(goodsFromDB.getGoodsUpdateTime());
            goodsHistoryTemp.setGoodsHscode(goodsFromDB.getGoodsHscode());
            goodsHistoryTemp.setGoodsCiqGoodsNo(goodsFromDB.getGoodsCiqGoodsNo());
            goodsHistoryTemp.setGoodsCustomsListNo(goodsFromDB.getGoodsCustomsListNo());
            goodsHistoryTemp.setGoodsPostageType(goodsFromDB.getGoodsPostageType());

            goodsHistoryListTemp.add(goodsHistoryTemp);
        }

        List<Goods> goodsListTemp = new ArrayList<Goods>();
        goodsListTemp.add(goodsFromDB);
        int doResultNum = goodsDAO.do_goods_save_and_history(goodsListTemp, goodsHistoryListTemp);
        if (doResultNum == IResult.UPDATE_EXCEPTION)
        {
            info = "商品更新失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_change_goods_up()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            info = "商品id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<Goods> goodsListTemp = goodsDAO.findByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (goodsListTemp == null)
        {
            info = "没有找到这些商品。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<GoodsHistory> goodsHistoryListTemp = new ArrayList<GoodsHistory>();
        for (Goods gTemp : goodsListTemp)
        {
            if (gTemp.getGoodsStatus().equals("准备中") || gTemp.getGoodsStatus().equals("已下架"))
            {
                gTemp.setGoodsStatus("销售中");
                gTemp.setGoodsUpdateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

                GoodsHistory goodsHistoryTemp = new GoodsHistory();

                goodsHistoryTemp.setHistoryId(CM.getRandomTwentyFivePrimaryKeyId());
                goodsHistoryTemp.setGoodsId(gTemp.getGoodsId());
                goodsHistoryTemp.setGoodsName(gTemp.getGoodsName());
                goodsHistoryTemp.setGoodsTips(gTemp.getGoodsTips());
                goodsHistoryTemp.setGoodsBrand(gTemp.getGoodsBrand());
                goodsHistoryTemp.setGoodsItemId(gTemp.getGoodsItemId());
                goodsHistoryTemp.setGoodsPrice(gTemp.getGoodsPrice());
                goodsHistoryTemp.setGoodsOriginalPrice(gTemp.getGoodsOriginalPrice());
                goodsHistoryTemp.setGoodsMinBuyNumber(gTemp.getGoodsMinBuyNumber());
                goodsHistoryTemp.setGoodsInventoryNumber(gTemp.getGoodsInventoryNumber());
                goodsHistoryTemp.setGoodsSalesNumber(gTemp.getGoodsSalesNumber());
                goodsHistoryTemp.setGoodsCommentNumber(gTemp.getGoodsCommentNumber());
                goodsHistoryTemp.setGoodsStartTime(gTemp.getGoodsStartTime());
                goodsHistoryTemp.setGoodsCommission(gTemp.getGoodsCommission());
                goodsHistoryTemp.setGoodsDiscount(gTemp.getGoodsDiscount());
                goodsHistoryTemp.setGoodsMainPic(gTemp.getGoodsMainPic());
                goodsHistoryTemp.setGoodsGallery(gTemp.getGoodsGallery());
                goodsHistoryTemp.setGoodsDetail(gTemp.getGoodsDetail());
                goodsHistoryTemp.setGoodsTypeId(gTemp.getGoodsTypeId());
                goodsHistoryTemp.setGoodsOperationMode(gTemp.getGoodsOperationMode());
                goodsHistoryTemp.setGoodsStatus(gTemp.getGoodsStatus());
                goodsHistoryTemp.setGoodsUpdateTime(gTemp.getGoodsUpdateTime());
                goodsHistoryTemp.setGoodsHscode(gTemp.getGoodsHscode());
                goodsHistoryTemp.setGoodsCiqGoodsNo(gTemp.getGoodsCiqGoodsNo());
                goodsHistoryTemp.setGoodsCustomsListNo(gTemp.getGoodsCustomsListNo());
                goodsHistoryTemp.setGoodsPostageType(gTemp.getGoodsPostageType());

                goodsHistoryListTemp.add(goodsHistoryTemp);
            }
        }
        if (goodsHistoryListTemp.size() <= 0)
        {
            info = "没有需要上架的商品。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        int doResultNum = goodsDAO.do_goods_save_and_history(goodsListTemp, goodsHistoryListTemp);
        if (doResultNum == IResult.UPDATE_EXCEPTION)
        {
            info = "上架商品失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_change_goods_down()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            info = "商品id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<Goods> goodsListTemp = goodsDAO.findByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (goodsListTemp == null)
        {
            info = "没有找到这些商品。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<GoodsHistory> goodsHistoryListTemp = new ArrayList<GoodsHistory>();
        for (Goods gTemp : goodsListTemp)
        {
            if (gTemp.getGoodsStatus().equals("销售中"))
            {
                gTemp.setGoodsStatus("已下架");
            }
        }
        int doResultNum = goodsDAO.do_goods_save_and_history(goodsListTemp, goodsHistoryListTemp);
        if (doResultNum == IResult.UPDATE_EXCEPTION)
        {
            info = "下架商品失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String show_order_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        String status = getRequest().getParameter("s");
        String keyword = getRequest().getParameter("k");
        int onePageSize = 20;
        List<Order> resList = null;
        int countTemp = 0;

        if (CM.validIsEmpty(status))
        {
            resList = orderDAO.getListByIndexAndPageSizeAndKeyword(index, onePageSize, keyword);
            countTemp = orderDAO.getTotalCountByKeyword(keyword);
        }
        else
        {
            resList = orderDAO.getListByIndexAndPageSizeAndStatusAnd_keyword(index, onePageSize, status, keyword);
            countTemp = orderDAO.getTotalCountByStatusAnd_keyword(status, keyword);
        }
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }

        List<ComplexOrder> complexOrderListTemp = new ArrayList<ComplexOrder>();
        for (Order orderTTT : resList)
        {
            ComplexOrder complexOrderTemp = new ComplexOrder();
            complexOrderTemp.setOrder(orderTTT);

            List<GoodsHistoryItem> goodsHistoryItemList = new ArrayList<GoodsHistoryItem>();
            List<OrderGoods> orderGoodsList = orderGoodsDAO.findByProperty(OrderGoodsDAO.ORDER_ID, orderTTT.getOrderId());
            for (OrderGoods orderGoods : orderGoodsList)
            {
                GoodsHistoryItem goodsHistoryItem = new GoodsHistoryItem();
                GoodsHistory goodsHistoryTemp = goodsHistoryDAO.findByGoodsIdAndGoodsUpdateTime(orderGoods.getGoodsId(), orderGoods.getGoodsUpdateTime());
                goodsHistoryItem.setGoodsHistory(goodsHistoryTemp);
                goodsHistoryItem.setNumber(orderGoods.getGoodsNumber());
                goodsHistoryItem.setCommentId(orderGoods.getCommentId());
                goodsHistoryItem.setCartAddTime(orderGoods.getOrderGoodsAddTime());
                goodsHistoryItemList.add(goodsHistoryItem);
            }
            complexOrderTemp.setGoodsHistoryItemList(goodsHistoryItemList);
            complexOrderListTemp.add(complexOrderTemp);
        }

        setComplexOrderList(complexOrderListTemp);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String show_return_order_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        String status = getRequest().getParameter("s");
        String keyword = getRequest().getParameter("k");
        int onePageSize = 20;
        List<OrderReturn> resList = null;
        int countTemp = 0;

        if (CM.validIsEmpty(status))
        {
            resList = orderReturnDAO.getListByIndexAndPageSizeAnd_keyword(index, onePageSize, keyword);
            countTemp = orderReturnDAO.getTotalCountBy_keyword(keyword);
        }
        else
        {
            resList = orderReturnDAO.getListByIndexAndPageSizeAndStatusAnd_keyword(index, onePageSize, status, keyword);
            countTemp = orderReturnDAO.getTotalCountByStatusAnd_keyword(status, keyword);
        }
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }

        List<ComplexOrderReturn> complexOrderReturnListTemp = new ArrayList<ComplexOrderReturn>();
        for (OrderReturn orT : resList)
        {
            ComplexOrderReturn corTemp = new ComplexOrderReturn();
            corTemp.setOrderReturn(orT);
            Order orderTTT = orderDAO.findById(orT.getOrderId());
            corTemp.setOrder(orderTTT);

            List<GoodsHistoryItem> goodsHistoryItemList = new ArrayList<GoodsHistoryItem>();
            List<OrderGoods> orderGoodsList = orderGoodsDAO.findByProperty(OrderGoodsDAO.ORDER_ID, orderTTT.getOrderId());
            for (OrderGoods orderGoods : orderGoodsList)
            {
                GoodsHistoryItem goodsHistoryItem = new GoodsHistoryItem();
                GoodsHistory goodsHistoryTemp = goodsHistoryDAO.findByGoodsIdAndGoodsUpdateTime(orderGoods.getGoodsId(), orderGoods.getGoodsUpdateTime());
                goodsHistoryItem.setGoodsHistory(goodsHistoryTemp);
                goodsHistoryItem.setNumber(orderGoods.getGoodsNumber());
                goodsHistoryItem.setCommentId(orderGoods.getCommentId());
                goodsHistoryItemList.add(goodsHistoryItem);
            }
            corTemp.setGoodsHistoryItemList(goodsHistoryItemList);

            complexOrderReturnListTemp.add(corTemp);
        }

        setComplexOrderReturnList(complexOrderReturnListTemp);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String show_buyer_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        String status = getRequest().getParameter("s");
        String keyword = getRequest().getParameter("k");
        int onePageSize = 20;
        List<Buyer> resList = null;
        int countTemp = 0;

        if (CM.validIsEmpty(status))
        {
            resList = buyerDAO.getListByIndexAndPageSizeAnd_keyword(index, onePageSize, keyword);
            countTemp = buyerDAO.getTotalCountBy_keyword(keyword);
        }
        else
        {
            resList = buyerDAO.getListByIndexAndPageSizeAndStatusAnd_keyword(index, onePageSize, status, keyword);
            countTemp = buyerDAO.getTotalCountByStatusAnd_keyword(status, keyword);
        }
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }

        setBuyerList(resList);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String m_add_express_info_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getOrder() == null)
        {
            info = "没有找到此订单，请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getOrder().getOrderId());
        validStrList.add(getOrder().getOrderExpressCompany());
        validStrList.add(getOrder().getOrderExpressNumber());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Order orderFromDB = orderDAO.findById(getOrder().getOrderId());
        if (orderFromDB == null)
        {
            info = "没有找到此订单。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        orderFromDB.setOrderExpressCompany(getOrder().getOrderExpressCompany());
        orderFromDB.setOrderExpressNumber(getOrder().getOrderExpressNumber());
        orderFromDB.setOrderStatus(IStatus.ORDER_TO_BE_RECEIVED);
        orderFromDB.setOrderSendTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

        Order orderResult = orderDAO.save(orderFromDB);
        if (orderResult == null)
        {
            info = "保存失败，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        // 给用户发送订单发货通知
        Buyer buyerFromDB = buyerDAO.findById(orderResult.getBuyerId());
        if (buyerFromDB != null)
        {
            CP.push_send_out_order_success(buyerFromDB.getBuyerWechat(), orderResult);
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_order_return_add_express_info_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getOrderReturn() == null)
        {
            info = "没有找到此退换货订单，请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getOrderReturn().getOrderReturnId());
        validStrList.add(getOrderReturn().getOrderSellerExpressCompany());
        validStrList.add(getOrderReturn().getOrderSellerExpressNumber());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        OrderReturn orderReturnFromDB = orderReturnDAO.findById(getOrderReturn().getOrderReturnId());
        if (orderReturnFromDB == null)
        {
            info = "没有找到此退换货订单。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        if ((orderReturnFromDB.getOrderReturnStatus().equals(IStatus.ORDER_RETURN_SELLER_PROCESSING) && orderReturnFromDB.getOrderReturnType().equals("换货")) == false)
        {
            info = "只有卖家处理中并且买家申请的是换货时才能填写快递信息。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        orderReturnFromDB.setOrderSellerExpressCompany(getOrderReturn().getOrderSellerExpressCompany());
        orderReturnFromDB.setOrderSellerExpressNumber(getOrderReturn().getOrderSellerExpressNumber());
        orderReturnFromDB.setOrderReturnStatus(IStatus.ORDER_RETURN_SELLER_PROCESSING);

        OrderReturn orderReturnResult = orderReturnDAO.save(orderReturnFromDB);
        if (orderReturnResult == null)
        {
            info = "保存失败，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        // 退换货卖家换货通知
        Buyer buyerFromDB = buyerDAO.findById(orderReturnResult.getBuyerId());
        if (buyerFromDB != null)
        {
            CP.push_order_return_seller_express_info(buyerFromDB.getBuyerWechat(), orderDAO.findById(orderReturnResult.getOrderId()), orderReturnResult);
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_forget_message_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        String id_pass = getRequest().getParameter("id");

        if (CM.validIsEmptyWithTrim(id_pass))
        {
            info = "没有找到此留言，请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        BuyerMessage buyerMessageFromDB = buyerMessageDAO.findById(id_pass);
        if (buyerMessageFromDB == null)
        {
            info = "没有找到此留言。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        buyerMessageFromDB.setBuyerMessageStatus(IStatus.BUYER_MESSAGE_STATUS_HAVE_FORGETTED);

        BuyerMessage buyerMessageResult = buyerMessageDAO.save(buyerMessageFromDB);
        if (buyerMessageResult == null)
        {
            info = "操作失败，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_add_reply_message_info_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getBuyerMessage() == null)
        {
            info = "没有找到此留言，请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getBuyerMessage().getBuyerMessageId());
        validStrList.add(getBuyerMessage().getBuyerMessageReply());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        BuyerMessage buyerMessageFromDB = buyerMessageDAO.findById(getBuyerMessage().getBuyerMessageId());
        if (buyerMessageFromDB == null)
        {
            info = "没有找到此留言。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Manager managerSession = (Manager) getSession().getAttribute("managerSession");

        buyerMessageFromDB.setBuyerMessageReply(getBuyerMessage().getBuyerMessageReply());
        buyerMessageFromDB.setBuyerMessageReplyTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
        buyerMessageFromDB.setBuyerMessageReplySellerId(managerSession.getManagerRealName());
        buyerMessageFromDB.setBuyerMessageStatus(IStatus.BUYER_MESSAGE_STATUS_HAVE_REPLYED);

        BuyerMessage buyerMessageResult = buyerMessageDAO.save(buyerMessageFromDB);
        if (buyerMessageResult == null)
        {
            info = "保存失败，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String add_reply_for_comment()
    {
        String idTemp = getRequest().getParameter("id");
        if (CM.validIsEmpty(idTemp))
        {
            return "404";
        }
        Comment commentFromDB = commentDAO.findById(idTemp);
        setComment(commentFromDB);
        return SUCCESS;
    }

    public String reply_buyer_message()
    {
        String idTemp = getRequest().getParameter("id");
        if (CM.validIsEmpty(idTemp))
        {
            return "404";
        }
        BuyerMessage buyerMessageFromDB = buyerMessageDAO.findById(idTemp);
        setBuyerMessage(buyerMessageFromDB);
        return SUCCESS;
    }

    public String m_add_new_comment_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getComment() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getComment().getCommentId());
        validStrList.add(getComment().getCommentReply());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Comment commentFromDB = commentDAO.findById(getComment().getCommentId());
        if (commentFromDB == null)
        {
            info = "没有找到此评论。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        if (commentFromDB.getCommentReply() != null)
        {
            info = "已经回复过评论，不能再次回复。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        Manager managerSession = (Manager) getSession().getAttribute("managerSession");
        commentFromDB.setCommentReply(getComment().getCommentReply());
        commentFromDB.setCommentReplySellerId(managerSession.getManagerName());
        commentFromDB.setCommentReplyTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

        Comment commentResult = commentDAO.save(commentFromDB);
        if (commentResult == null)
        {
            info = "回复评论保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_count_number_do()
    {
        int on_sale_number = goodsDAO.getGoodsTotalCountByStatusAnd_tidAnd_keyword(IStatus.GOODS_IS_ON_SALE, null, null);
        int to_be_send_number = orderDAO.getTotalCountByStatusAnd_keyword(IStatus.ORDER_TO_BE_SEND, null);
        json.put("on_sale_number", on_sale_number >= 0 ? on_sale_number : 0);
        json.put("to_be_send_number", to_be_send_number >= 0 ? to_be_send_number : 0);
        json.put("success", true);
        return SUCCESS;
    }

    public String shop_update_shop()
    {
        Shop shopTemp = (Shop) getApplication().getAttribute("shopApplication");
        Shop shopFromDB = shopDAO.findById(shopTemp.getShopId());
        setShop(shopFromDB);
        return SUCCESS;
    }

    public String shop_update_province_postage()
    {
        setProvincePostageList(provincePostageDAO.findAll());
        return SUCCESS;
    }

    public String m_update_shop_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getShop() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Shop shopTemp = (Shop) getApplication().getAttribute("shopApplication");
        Shop shopFromDB = shopDAO.findById(shopTemp.getShopId());
        if (shopFromDB == null)
        {
            info = "没有找到此店铺。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        shopFromDB.setMzcMinNumber(getShop().getMzcMinNumber());
        shopFromDB.setQianhuiMinLimit(getShop().getQianhuiMinLimit());

        Shop shopResult = shopDAO.save(shopFromDB);
        if (shopResult == null)
        {
            info = "修改店铺信息失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        getApplication().setAttribute("shopApplication", shopResult);
        json.put("success", true);
        return SUCCESS;
    }

    public String m_add_coupon_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCoupon() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getCoupon().getCouponName());
        validStrList.add(getCoupon().getCouponType());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        if (getCoupon().getCouponType().equals("满减") && (getCoupon().getParam1() == null || getCoupon().getParam2() == null))
        {
            info = "满减类型的优惠券两个参数都要填写。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        if (getCoupon().getCouponType().equals("立减") && getCoupon().getParam1() == null)
        {
            info = "立减类型的优惠券第一个参数必须填写。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Calendar cal = Calendar.getInstance();
        cal.setTime(getCoupon().getCouponUseEndTime());
        cal.set(Calendar.HOUR_OF_DAY, 23);
        cal.set(Calendar.MINUTE, 59);
        cal.set(Calendar.SECOND, 59);
        getCoupon().setCouponUseEndTime(new Timestamp(cal.getTimeInMillis()));
        Calendar cal2 = Calendar.getInstance();
        cal2.setTime(getCoupon().getCouponSnapEndTime());
        cal2.set(Calendar.HOUR_OF_DAY, 23);
        cal2.set(Calendar.MINUTE, 59);
        cal2.set(Calendar.SECOND, 59);
        getCoupon().setCouponSnapEndTime(new Timestamp(cal2.getTimeInMillis()));

        if (getCoupon().getCouponUseBeginTime().before(getCoupon().getCouponUseEndTime()) == false || getCoupon().getCouponSnapBeginTime().before(getCoupon().getCouponSnapEndTime()) == false)
        {
            info = "开始时间要早于结束时间。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        if (getCoupon().getCouponSnapBeginTime().after(getCoupon().getCouponUseBeginTime()) || getCoupon().getCouponSnapEndTime().after(getCoupon().getCouponUseEndTime()))
        {
            info = "抢购开始时间不能晚于使用开始时间，抢购结束时间不能晚于使用结束时间。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        getCoupon().setCouponId(CM.getRandomTwentyFivePrimaryKeyId());
        getCoupon().setCouponCreateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
        Coupon couponResult = couponDAO.save(getCoupon());
        if (couponResult == null)
        {
            info = "优惠券保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String show_coupon_info_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        int onePageSize = 20;
        List<Coupon> resList = null;
        int countTemp = 0;

        resList = couponDAO.getListByIndexAndPageSize(index, onePageSize);
        countTemp = couponDAO.getTotalCount();
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }

        setCouponList(resList);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String shop_update_coupon()
    {
        // 得到此商品的信息
        String coupon_id_str = getRequest().getParameter("id");
        if (coupon_id_str == null || CM.validIsEmpty(coupon_id_str))
        {
            return ERROR;
        }
        Coupon couponTemp = couponDAO.findById(coupon_id_str);
        setCoupon(couponTemp);
        return SUCCESS;
    }

    public String m_update_coupon_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCoupon() == null || CM.validIsEmpty(getCoupon().getCouponId()))
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Coupon couponFromDB = couponDAO.findById(getCoupon().getCouponId());
        if (couponFromDB == null)
        {
            info = "没有找到此优惠券。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        couponFromDB.setCouponNumber(getCoupon().getCouponNumber());
        Coupon couponRes = couponDAO.save(couponFromDB);
        if (couponRes == null)
        {
            info = "优惠券更新失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_add_article_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getArticle() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getArticle().getArticleName());
        validStrList.add(getArticle().getArticleDetail());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Manager managerSession = (Manager) getSession().getAttribute("managerSession");
        getArticle().setArticleId(CM.getRandomTwentyFivePrimaryKeyId());
        getArticle().setUserId(managerSession.getManagerRealName());
        Timestamp timestampTemp = new Timestamp(Calendar.getInstance().getTimeInMillis());
        getArticle().setArticleStartTime(timestampTemp);
        getArticle().setArticleUpdateTime(timestampTemp);

        Article articleResult = articleDAO.save(getArticle());
        if (articleResult == null)
        {
            info = "文章保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String shop_update_article()
    {
        // 得到此商品的信息
        String article_id_str = getRequest().getParameter("id");
        if (article_id_str == null || CM.validIsEmpty(article_id_str))
        {
            return ERROR;
        }
        Article articleTemp = articleDAO.findById(article_id_str);
        setArticle(articleTemp);
        return SUCCESS;
    }

    public String show_article_info_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        String keyword = getRequest().getParameter("k");
        int onePageSize = 20;
        List<Article> resList = null;
        int countTemp = 0;
        resList = articleDAO.getListByIndexAndPageSizeAnd_keyword(index, onePageSize, keyword);
        countTemp = articleDAO.getTotalCountBy_keyword(keyword);
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        setArticleList(resList);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String show_message_info_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        String status = getRequest().getParameter("s");
        int onePageSize = 20;
        List<BuyerMessage> resList = null;
        int countTemp = 0;

        if (CM.validIsEmpty(status))
        {
            resList = buyerMessageDAO.getListByIndexAndPageSize(index, onePageSize);
            countTemp = buyerMessageDAO.getTotalCount();
        }
        else
        {
            resList = buyerMessageDAO.getListByStatusAndIndexAndPageSize(status, index, onePageSize);
            countTemp = buyerMessageDAO.getTotalCountByStatus(status);
        }
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }

        List<BuyerMessageView> buyerMessageViewListTemp = new ArrayList<BuyerMessageView>();
        for (BuyerMessage bmt : resList)
        {
            BuyerMessageView buyerMessageViewTemp = new BuyerMessageView();

            buyerMessageViewTemp.setBuyerMessage(bmt);
            Goods goodsTemp = goodsDAO.findById(bmt.getGoodsId());
            buyerMessageViewTemp.setGoods(goodsTemp);

            buyerMessageViewListTemp.add(buyerMessageViewTemp);
        }

        setBuyerMessageViewList(buyerMessageViewListTemp);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String m_update_article_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getArticle() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getArticle().getArticleId());
        validStrList.add(getArticle().getArticleName());
        validStrList.add(getArticle().getArticleDetail());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Article articleFromDB = articleDAO.findById(getArticle().getArticleId());
        if (articleFromDB == null)
        {
            info = "没有找到此文章。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        articleFromDB.setArticleName(getArticle().getArticleName());
        articleFromDB.setArticleTips(getArticle().getArticleTips());
        articleFromDB.setArticleDetail(getArticle().getArticleDetail());
        articleFromDB.setArticleUpdateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

        Article articleResult = articleDAO.save(articleFromDB);
        if (articleResult == null)
        {
            info = "文章保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String show_article_detail()
    {
        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            return "404";
        }
        Article articleTemp = articleDAO.findById(getCommonStr());
        setArticle(articleTemp);
        return SUCCESS;
    }

    public String m_agree_apply_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            info = "退换货id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<OrderReturn> orderReturnListTemp = orderReturnDAO.findByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (orderReturnListTemp == null || orderReturnListTemp.size() == 0)
        {
            info = "没有找到这些退换货订单。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        for (OrderReturn orTemp : orderReturnListTemp)
        {
            if (orTemp.getOrderReturnStatus().equals(IStatus.ORDER_RETURN_APPLY_VERIFYING))
            {
                orTemp.setOrderReturnStatus(IStatus.ORDER_RETURN_BUYER_RETURNING);
            }
        }

        List<OrderReturn> orderReturnListResult = orderReturnDAO.saveList(orderReturnListTemp);
        if (orderReturnListResult == null || orderReturnListResult.size() == 0)
        {
            info = "操作失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        // 退换货审核通知
        for (OrderReturn orTemp : orderReturnListResult)
        {
            Buyer buyerFromDB = buyerDAO.findById(orTemp.getBuyerId());
            if (buyerFromDB != null)
            {
                CP.push_order_return_auth_result(buyerFromDB.getBuyerWechat(), orderDAO.findById(orTemp.getOrderId()), orTemp);
            }
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_refuse_apply_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            info = "退换货id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<OrderReturn> orderReturnListTemp = orderReturnDAO.findByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (orderReturnListTemp == null || orderReturnListTemp.size() == 0)
        {
            info = "没有找到这些退换货订单。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        for (OrderReturn orTemp : orderReturnListTemp)
        {
            if (orTemp.getOrderReturnStatus().equals(IStatus.ORDER_RETURN_APPLY_VERIFYING))
            {
                orTemp.setOrderReturnStatus(IStatus.ORDER_RETURN_APPLY_REFUSED);
            }
        }

        List<OrderReturn> orderReturnListResult = orderReturnDAO.saveList(orderReturnListTemp);
        if (orderReturnListResult == null || orderReturnListResult.size() == 0)
        {
            info = "操作失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        // 退换货审核通知
        for (OrderReturn orTemp : orderReturnListResult)
        {
            Buyer buyerFromDB = buyerDAO.findById(orTemp.getBuyerId());
            if (buyerFromDB != null)
            {
                CP.push_order_return_auth_result(buyerFromDB.getBuyerWechat(), orderDAO.findById(orTemp.getOrderId()), orTemp);
            }
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_delete_special_commission_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            info = "特殊佣金id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<GoodsCommission> goodsCommissionListTemp = goodsCommissionDAO.findByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (goodsCommissionListTemp == null || goodsCommissionListTemp.size() == 0)
        {
            info = "没有找到这些特殊佣金。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        int del_res = goodsCommissionDAO.batch_delete(goodsCommissionListTemp);

        if (del_res != IResult.DELETE_SUCCESS)
        {
            info = "删除时出现错误，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_confirm_receive_buyer_express_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            info = "退换货id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<OrderReturn> orderReturnListTemp = orderReturnDAO.findByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (orderReturnListTemp == null || orderReturnListTemp.size() == 0)
        {
            info = "没有找到这些退换货订单。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        for (OrderReturn orTemp : orderReturnListTemp)
        {
            if (orTemp.getOrderReturnStatus().equals(IStatus.ORDER_RETURN_BUYER_RETURNING) && CM.validIsEmptyWithTrim(orTemp.getOrderBuyerExpressCompany()) == false)
            {
                orTemp.setOrderReturnStatus(IStatus.ORDER_RETURN_SELLER_PROCESSING);
            }
        }

        List<OrderReturn> orderReturnListResult = orderReturnDAO.saveList(orderReturnListTemp);
        if (orderReturnListResult == null || orderReturnListResult.size() == 0)
        {
            info = "操作失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_confirm_send_buyer_money_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            info = "退换货id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<OrderReturn> orderReturnListTemp = orderReturnDAO.findByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (orderReturnListTemp == null || orderReturnListTemp.size() == 0)
        {
            info = "没有找到这些退换货订单。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<Order> orderListTemp = new ArrayList<Order>();
        for (OrderReturn orTemp : orderReturnListTemp)
        {
            if (orTemp.getOrderReturnStatus().equals(IStatus.ORDER_RETURN_SELLER_PROCESSING) && orTemp.getOrderReturnType().equals("退货"))
            {
                orTemp.setOrderReturnStatus(IStatus.ORDER_RETURN_HAVE_BEEN_COMPLETED);
                Order orderTemp = orderDAO.findById(orTemp.getOrderId());
                orderTemp.setOrderStatus(IStatus.ORDER_TO_BE_COMMENTED);
                orderListTemp.add(orderTemp);
            }
        }

        List<OrderReturn> orderReturnListResult = orderReturnDAO.batch_save_return_and_order(orderReturnListTemp, orderListTemp);
        if (orderReturnListResult == null || orderReturnListResult.size() == 0)
        {
            info = "操作失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        // 退款给买家通知
        for (OrderReturn orTemp : orderReturnListResult)
        {
            Buyer buyerFromDB = buyerDAO.findById(orTemp.getBuyerId());
            if (buyerFromDB != null)
            {
                CP.push_order_return_money_info(buyerFromDB.getBuyerWechat(), orderDAO.findById(orTemp.getOrderId()), orTemp);
            }
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_set_buyer_forever_qrcode_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getCommonStr() == null || CM.validIsEmpty(getCommonStr()))
        {
            info = "买家id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<Buyer> buyerListTemp = buyerDAO.findByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (buyerListTemp == null || buyerListTemp.size() == 0)
        {
            info = "没有找到这些用户。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<Buyer> need_update_buyer_list = new ArrayList<Buyer>();

        for (Buyer bTemp : buyerListTemp)
        {
            // 如果没有获取过,先获取
            if (bTemp.getBuyerQrcodeId() == null || bTemp.getBuyerQrcodeUrl() == null)
            {

                Calendar calendar = Calendar.getInstance();
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy");
                SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
                SimpleDateFormat sdf3 = new SimpleDateFormat("dd");
                String path = getRequest().getContextPath();
                String basePath = getRequest().getScheme() + "://" + getRequest().getServerName() + ":" + getRequest().getServerPort() + path + "/";
                String root_path = getRealPath("/");
                String save_folder = "qrcode_limit/" + sdf1.format(calendar.getTime()) + "/" + sdf2.format(calendar.getTime()) + "/" + sdf3.format(calendar.getTime());
                String file_name = CM.getRandomTwentyFivePrimaryKeyId() + ".jpg";

                File folder = new File(root_path + save_folder);
                if (folder.exists() == false)
                {
                    folder.mkdirs();
                }

                String access_token = TokenManager.getToken(GlobalConfig.appID);
                int scene_id = CM.getIntRandomNumberLessThan100000();
                QrcodeTicket qrcodeTicket = QrcodeAPI.qrcodeCreateFinal(access_token, scene_id);

                BufferedImage image = QrcodeAPI.showqrcode(qrcodeTicket.getTicket());
                File newFile = new File(root_path + save_folder + "/" + file_name);
                try
                {
                    ImageIO.write(image, "jpg", newFile);

                    BufferedImage big = image;
                    BufferedImage small = ImageIO.read(new File(root_path + "file/qrcode_center_logo.jpg"));

                    BufferedImage bufImage = new BufferedImage(big.getWidth(), big.getHeight(), BufferedImage.TYPE_INT_RGB);
                    Graphics g = bufImage.createGraphics();
                    g.drawImage(big, 0, 0, big.getWidth(), big.getHeight(), null);

                    int x = (big.getWidth() - small.getWidth()) / 2;
                    int y = (big.getHeight() - small.getHeight()) / 2;
                    g.drawImage(small, x, y, small.getWidth(), small.getHeight(), null);
                    g.dispose();
                    // ImageIO.write(bufImage, "jpg", new File("D:/new.jpg"));

                    int[] sizeArr = {1280, 860, 430, 344, 258};
                    for (int i : sizeArr)
                    {
                        BufferedImage temp_img = new BufferedImage(i, i, BufferedImage.TYPE_INT_RGB);
                        temp_img.getGraphics().drawImage(bufImage, 0, 0, i, i, null);
                        ImageIO.write(temp_img, "jpg", new File(root_path + save_folder + "/" + file_name.replaceAll(".jpg", "_" + i + ".jpg")));
                    }
                } catch (IOException e)
                {
                    return SUCCESS;
                }

                bTemp.setBuyerQrcodeId(scene_id);
                bTemp.setBuyerQrcodeUrl(basePath + save_folder + "/" + file_name);
                bTemp.setBuyerQrcodeBeginTime(new Timestamp(calendar.getTimeInMillis()));
                calendar.add(Calendar.YEAR, 50);
                bTemp.setBuyerQrcodeEndTime(new Timestamp(calendar.getTimeInMillis()));

                need_update_buyer_list.add(bTemp);
            }
            else
            {
                Calendar cal_1 = Calendar.getInstance();
                cal_1.setTime(bTemp.getBuyerQrcodeBeginTime());
                cal_1.add(Calendar.DAY_OF_MONTH, 8);
                Calendar cal_2 = Calendar.getInstance();
                cal_2.setTime(bTemp.getBuyerQrcodeEndTime());
                // 如果是临时二维码的话，转为永久二维码
                if (cal_1.after(cal_2))
                {
                    Calendar calendar = Calendar.getInstance();
                    SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy");
                    SimpleDateFormat sdf2 = new SimpleDateFormat("MM");
                    SimpleDateFormat sdf3 = new SimpleDateFormat("dd");
                    String path = getRequest().getContextPath();
                    String basePath = getRequest().getScheme() + "://" + getRequest().getServerName() + ":" + getRequest().getServerPort() + path + "/";
                    String root_path = getRealPath("/");
                    String save_folder = "qrcode_limit/" + sdf1.format(calendar.getTime()) + "/" + sdf2.format(calendar.getTime()) + "/" + sdf3.format(calendar.getTime());
                    String file_name = CM.getRandomTwentyFivePrimaryKeyId() + ".jpg";

                    File folder = new File(root_path + save_folder);
                    if (folder.exists() == false)
                    {
                        folder.mkdirs();
                    }

                    String access_token = TokenManager.getToken(GlobalConfig.appID);
                    int scene_id = CM.getIntRandomNumberLessThan100000();
                    QrcodeTicket qrcodeTicket = QrcodeAPI.qrcodeCreateFinal(access_token, scene_id);

                    BufferedImage image = QrcodeAPI.showqrcode(qrcodeTicket.getTicket());
                    File newFile = new File(root_path + save_folder + "/" + file_name);
                    try
                    {
                        ImageIO.write(image, "jpg", newFile);
                    } catch (IOException e)
                    {
                        return SUCCESS;
                    }

                    bTemp.setBuyerQrcodeId(scene_id);
                    bTemp.setBuyerQrcodeUrl(basePath + save_folder + "/" + file_name);
                    bTemp.setBuyerQrcodeBeginTime(new Timestamp(calendar.getTimeInMillis()));
                    calendar.add(Calendar.YEAR, 50);
                    bTemp.setBuyerQrcodeEndTime(new Timestamp(calendar.getTimeInMillis()));

                    need_update_buyer_list.add(bTemp);
                }
            }
        }

        List<Buyer> buyerListResult = buyerDAO.saveList(need_update_buyer_list);

        if (buyerListResult == null || buyerListResult.size() == 0)
        {
            info = "操作失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_add_special_commission_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getGoodsCommission() == null)
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getGoodsCommission().getBuyerId());
        validStrList.add(getGoodsCommission().getGoodsId());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Buyer buyerFromDB = buyerDAO.findById(getGoodsCommission().getBuyerId());
        if (buyerFromDB == null)
        {
            info = "没有找到此用户。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        Goods goodsFromDB = goodsDAO.findById(getGoodsCommission().getGoodsId());
        if (goodsFromDB == null)
        {
            info = "没有找到此商品。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        getGoodsCommission().setGoodsCommissionId(CM.getRandomTwentyFivePrimaryKeyId());
        getGoodsCommission().setCommissionUpdateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

        GoodsCommission goodsCommissionResult = goodsCommissionDAO.save(getGoodsCommission());
        if (goodsCommissionResult == null)
        {
            info = "保存失败，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_update_special_commission_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getGoodsCommission() == null)
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getGoodsCommission().getGoodsCommissionId());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        GoodsCommission goodsCommissionFromDB = goodsCommissionDAO.findById(getGoodsCommission().getGoodsCommissionId());
        if (goodsCommissionFromDB == null)
        {
            info = "没有找到此特殊佣金。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        goodsCommissionFromDB.setGoodsCommission(getGoodsCommission().getGoodsCommission());
        goodsCommissionFromDB.setCommissionUpdateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

        GoodsCommission goodsCommissionResult = goodsCommissionDAO.save(goodsCommissionFromDB);
        if (goodsCommissionResult == null)
        {
            info = "保存失败，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String show_special_commission_info_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        String goodsId = getRequest().getParameter("goodsId");
        String buyerId = getRequest().getParameter("buyerId");

        if (CM.validIsEmptyWithTrim(goodsId) && CM.validIsEmptyWithTrim(buyerId))
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }

        int onePageSize = 20;
        List<GoodsCommission> resList = null;
        int countTemp = 0;

        if (CM.validIsEmptyWithTrim(goodsId) == false)
        {
            resList = goodsCommissionDAO.getListByGoodsIdAndIndexAndPageSize(goodsId, index, onePageSize);
            countTemp = goodsCommissionDAO.getTotalCountByGoodsId(goodsId);
        }
        else if (CM.validIsEmptyWithTrim(buyerId) == false)
        {
            resList = goodsCommissionDAO.getListByBuyerIdAndIndexAndPageSize(buyerId, index, onePageSize);
            countTemp = goodsCommissionDAO.getTotalCountByBuyerId(buyerId);
        }
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }

        List<GoodsCommissionView> goodsCommissionViewListTemp = new ArrayList<GoodsCommissionView>();
        for (GoodsCommission gcTemp : resList)
        {
            GoodsCommissionView commissionViewTemp = new GoodsCommissionView();
            commissionViewTemp.setGoodsCommission(gcTemp);
            commissionViewTemp.setBuyer(buyerDAO.findById(gcTemp.getBuyerId()));
            commissionViewTemp.setGoods(goodsDAO.findById(gcTemp.getGoodsId()));
            goodsCommissionViewListTemp.add(commissionViewTemp);
        }
        setGoodsCommissionViewList(goodsCommissionViewListTemp);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String shop_update_special_commission()
    {
        // 得到此文章的信息
        String idStr = getRequest().getParameter("id");
        if (CM.validIsEmpty(idStr) == true)
        {
            return "404";
        }
        GoodsCommission goodsCommissionFromDB = goodsCommissionDAO.findById(idStr);
        setGoodsCommission(goodsCommissionFromDB);
        return SUCCESS;
    }

    public String m_import_special_commission_do() throws IOException
    {
        // 获取文件存储路径
        String path = getRealPath("/") + "file/upload/";
        // 输出流
        String tempFileName = CM.getRandomTwentyFivePrimaryKeyId() + ".xlsx";
        OutputStream os = new FileOutputStream(new File(path, tempFileName));
        // 输入流
        InputStream is = new FileInputStream(excelFile);

        byte[] buf = new byte[1024];
        int length = 0;

        while (-1 != (length = is.read(buf)))
        {
            os.write(buf, 0, length);
        }
        is.close();
        os.close();

        try
        {
            ExcelReader excelReader = new ExcelReader();
            // 对读取Excel表格标题测试
            InputStream excel_is = new FileInputStream(new File(path + tempFileName));

            String[] title = excelReader.readExcelTitle(excel_is);
            System.out.println("获得Excel表格的标题:");
            for (String s : title)
            {
                System.out.print(s + " ");
            }

            // 对读取Excel表格内容测试
            InputStream excel_is2 = new FileInputStream(new File(path, tempFileName));
            Map<Integer, String> map = excelReader.readExcelContent(excel_is2);
            System.out.println("获得Excel表格的内容:");
            List<GoodsCommission> goodsCommissionListForSave = new ArrayList<GoodsCommission>();
            for (int i = 1; i <= map.size(); i++)
            {
                System.out.println(map.get(i));
                String[] tempArray = map.get(i).split("\t");

                GoodsCommission goodsCommissionFromDB = goodsCommissionDAO.findByGoodsIdAndBuyerId(tempArray[1], tempArray[0]);
                if (goodsCommissionFromDB == null)
                {
                    goodsCommissionFromDB = new GoodsCommission();
                    goodsCommissionFromDB.setGoodsCommissionId(CM.getRandomTwentyFivePrimaryKeyId());
                    goodsCommissionFromDB.setBuyerId(tempArray[0]);
                    goodsCommissionFromDB.setGoodsId(tempArray[1]);
                    goodsCommissionFromDB.setGoodsCommission(Double.parseDouble(tempArray[2]));
                    goodsCommissionFromDB.setCommissionUpdateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
                }
                else
                {
                    goodsCommissionFromDB.setGoodsCommission(Double.parseDouble(tempArray[2]));
                    goodsCommissionFromDB.setCommissionUpdateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
                }

                goodsCommissionListForSave.add(goodsCommissionFromDB);
            }

            List<GoodsCommission> goodsCommissionListResult = goodsCommissionDAO.saveList(goodsCommissionListForSave);
            if (goodsCommissionListResult == null || goodsCommissionListResult.size() == 0)
            {
                info = "保存0条记录，请检查Excel是否满足要求。";
                json.put("success", false);
                json.put("info", info);
                return SUCCESS;
            }

        } catch (FileNotFoundException e)
        {
            System.out.println("未找到指定路径的文件!");
            e.printStackTrace();
            info = "处理文件时出错，请检查Excel是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_add_kefu_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getKefu() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getKefu().getBuyerId());
        validStrList.add(getKefu().getKefuNickname());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Buyer buyerFromDB = buyerDAO.findById(getKefu().getBuyerId());
        if (buyerFromDB == null)
        {
            info = "没有找到此买家。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Kefu kefuFromDB = kefuDAO.findByBuyerId(getKefu().getBuyerId());
        if (kefuFromDB != null)
        {
            info = "已经添加过了，无需重复添加。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        getKefu().setKefuId(CM.getRandomTwentyFivePrimaryKeyId());
        getKefu().setKefuAddTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

        Kefu kefuResult = kefuDAO.save(getKefu());
        if (kefuResult == null)
        {
            info = "保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_update_kefu_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getKefu() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getKefu().getKefuId());
        validStrList.add(getKefu().getKefuNickname());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Kefu kefuFromDB = kefuDAO.findById(getKefu().getKefuId());
        if (kefuFromDB == null)
        {
            info = "没有找到此条记录。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        kefuFromDB.setKefuNickname(getKefu().getKefuNickname());

        Kefu kefuResult = kefuDAO.save(kefuFromDB);
        if (kefuResult == null)
        {
            info = "保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String show_kefu_info_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        int onePageSize = 20;
        List<Kefu> resList = null;
        int countTemp = 0;

        resList = kefuDAO.findAll();
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }

        List<KefuView> kefuViewListTemp = new ArrayList<KefuView>();
        for (Kefu kTemp : resList)
        {
            KefuView kefuView = new KefuView();
            kefuView.setBuyer(buyerDAO.findById(kTemp.getBuyerId()));
            kefuView.setKefu(kTemp);

            kefuViewListTemp.add(kefuView);
        }
        setKefuViewList(kefuViewListTemp);

        return SUCCESS;
    }

    public String shop_update_kefu()
    {
        // 得到此商品的信息
        String kefu_id_str = getRequest().getParameter("id");
        if (kefu_id_str == null || CM.validIsEmpty(kefu_id_str))
        {
            return ERROR;
        }
        Kefu kefuTemp = kefuDAO.findById(kefu_id_str);
        setKefu(kefuTemp);
        return SUCCESS;
    }

    public String shop_update_buyer()
    {
        // 得到此商品的信息
        String id_str = getRequest().getParameter("id");
        if (id_str == null || CM.validIsEmpty(id_str))
        {
            return ERROR;
        }
        Buyer buyerTemp = buyerDAO.findById(id_str);
        setBuyer(buyerTemp);
        return SUCCESS;
    }

    public String m_update_buyer_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getBuyer() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getBuyer().getBuyerId());
        validStrList.add(getBuyer().getBuyerType());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Buyer buyerFromDB = buyerDAO.findById(getBuyer().getBuyerId());
        if (buyerFromDB == null)
        {
            info = "没有找到此条记录。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        if (CM.validIsEmptyWithTrim(getBuyer().getBuyerIntroducer()) == false)
        {
            buyerFromDB.setBuyerIntroducer(getBuyer().getBuyerIntroducer());
        }

        buyerFromDB.setBuyerType(getBuyer().getBuyerType());

        Buyer buyerResult = buyerDAO.save(buyerFromDB);
        if (buyerResult == null)
        {
            info = "保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_add_a_pic_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getAdvertisement() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getAdvertisement().getAdvertisementType());
        validStrList.add(getAdvertisement().getAdvertisementLink());
        validStrList.add(getAdvertisement().getAdvertisementPicture());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<String> advertisement_pictureTemp = CM.getImgSrcList(getAdvertisement().getAdvertisementPicture(), 1);
        if (advertisement_pictureTemp == null)
        {
            info = "图片上传是必选项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        getAdvertisement().setAdvertisementPicture(advertisement_pictureTemp.get(0));
        Manager managerSession = (Manager) getSession().getAttribute("managerSession");
        getAdvertisement().setAdvertisementId(CM.getRandomTwentyFivePrimaryKeyId());
        getAdvertisement().setUserId(managerSession.getManagerRealName());
        Timestamp timestampTemp = new Timestamp(Calendar.getInstance().getTimeInMillis());
        getAdvertisement().setAdvertisementAddTime(timestampTemp);
        getAdvertisement().setAdvertisementUpdateTime(timestampTemp);

        Advertisement advertisementResult = advertisementDAO.save(getAdvertisement());
        if (advertisementResult == null)
        {
            info = "宣传图片保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String show_a_pic_info_list()
    {
        // 获取分页
        String iPass = getRequest().getParameter("i");
        int index = 1;
        try
        {
            index = Integer.parseInt(iPass);
        } catch (Exception e)
        {
            index = 1;
        }

        String type = getRequest().getParameter("type");
        int onePageSize = 20;
        List<Advertisement> resList = null;
        int countTemp = 0;
        resList = advertisementDAO.getListByIndexAndPageSizeAnd_type_userId(index, onePageSize, type, null);
        countTemp = advertisementDAO.getTotalCountBy_type_userId(type, null);
        if (resList == null)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        if (countTemp == -1)
        {
            info = "参数有误，暂未查到。";
            return SUCCESS;
        }
        setAdvertisementList(resList);
        int ttpTemp = countTemp % onePageSize == 0 ? countTemp / onePageSize : countTemp / onePageSize + 1;
        Page pageTemp = new Page();
        pageTemp.setCurrentIndex(index);
        pageTemp.setTotalPages(ttpTemp);
        setPage(pageTemp);
        return SUCCESS;
    }

    public String shop_update_a_pic()
    {
        String idStr = getRequest().getParameter("id");
        if (CM.validIsEmpty(idStr) == true)
        {
            return "404";
        }
        Advertisement advertisementFromDB = advertisementDAO.findById(idStr);
        setAdvertisement(advertisementFromDB);
        return SUCCESS;
    }

    public String m_update_a_pic_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getAdvertisement() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getAdvertisement().getAdvertisementId());
        validStrList.add(getAdvertisement().getAdvertisementLink());
        validStrList.add(getAdvertisement().getAdvertisementPicture());
        validStrList.add(getAdvertisement().getAdvertisementType());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<String> advertisement_pictureTemp = CM.getImgSrcList(getAdvertisement().getAdvertisementPicture(), 1);
        if (advertisement_pictureTemp == null)
        {
            info = "图片上传是必选项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Advertisement advertisementFromDB = advertisementDAO.findById(getAdvertisement().getAdvertisementId());
        if (advertisementFromDB == null)
        {
            info = "没有找到此宣传图片。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        advertisementFromDB.setAdvertisementLink(getAdvertisement().getAdvertisementLink());
        advertisementFromDB.setAdvertisementPicture(advertisement_pictureTemp.get(0));
        advertisementFromDB.setAdvertisementTitle(getAdvertisement().getAdvertisementTitle());
        advertisementFromDB.setAdvertisementType(getAdvertisement().getAdvertisementType());

        advertisementFromDB.setAdvertisementUpdateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
        Advertisement advertisementResult = advertisementDAO.save(advertisementFromDB);
        if (advertisementResult == null)
        {
            info = "宣传图片保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_delete_a_pic_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (CM.validIsEmpty(getCommonStr()))
        {
            info = "宣传图片id是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        int delResult = advertisementDAO.deleteByIdList(CM.fromSomePictureSrcToOneList(getCommonStr()));
        if (delResult == IResult.DELETE_EXCEPTION)
        {
            info = "删除宣传图片失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_set_a_pic_order_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (CM.validIsEmptyWithTrim(getCommonStr()))
        {
            info = "没有找到需要提交的排序。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<String> idList = CM.fromSomePictureSrcToOneList(getCommonStr());
        List<Advertisement> advertisementListFromDB = advertisementDAO.findByIdList(idList);

        Map<String, Advertisement> adMap = new HashMap<String, Advertisement>();
        List<Advertisement> toBeSavedList = new ArrayList<Advertisement>();
        Calendar calendar_now = Calendar.getInstance();
        for (Advertisement aTemp : advertisementListFromDB)
        {
            adMap.put(aTemp.getAdvertisementId(), aTemp);
        }

        for (String idTemp : idList)
        {
            Advertisement tempAd = adMap.get(idTemp);
            calendar_now.add(Calendar.SECOND, -1);
            if (tempAd != null)
            {
                tempAd.setAdvertisementUpdateTime(new Timestamp(calendar_now.getTimeInMillis()));
                toBeSavedList.add(tempAd);
            }
        }

        List<Advertisement> saveResultList = advertisementDAO.saveList(toBeSavedList);
        if (saveResultList == null)
        {
            info = "保存排序结果失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_add_manager_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getManager() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getManager().getManagerName());
        validStrList.add(getManager().getManagerPassword());
        validStrList.add(getManager().getManagerEmail());
        validStrList.add(getManager().getManagerRealName());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        getManager().setManagerAddTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
        Manager managerResult = managerDAO.save(getManager());
        if (managerResult == null)
        {
            info = "管理员保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        String[] moduleNamesArray = getRequest().getParameterValues("moduleNamesArray");
        String[] moduleCheckedArray = getRequest().getParameterValues("moduleCheckedArray");

        List<ManagerModule> managerModuleListForSave = new ArrayList<ManagerModule>();
        Calendar cal = Calendar.getInstance();
        for (int i = 0; i < moduleCheckedArray.length; i++)
        {
            if (moduleCheckedArray[i].equals("1"))
            {
                ManagerModule managerModuleTemp = new ManagerModule();
                managerModuleTemp.setId(CM.getRandomTwentyFivePrimaryKeyId());
                managerModuleTemp.setManagerName(managerResult.getManagerName());
                managerModuleTemp.setModuleName(moduleNamesArray[i]);
                cal.add(Calendar.SECOND, 1);
                managerModuleTemp.setModuleAddTime(new Timestamp(cal.getTimeInMillis()));
                managerModuleListForSave.add(managerModuleTemp);
            }
        }

        List<ManagerModule> listResult = managerModuleDAO.saveList(managerModuleListForSave);

        json.put("success", true);
        return SUCCESS;
    }

    public String m_update_manager_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (getManager() == null)
        {
            info = "请检查输入项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<String> validStrList = new ArrayList<String>();
        validStrList.add(getManager().getManagerName());
        validStrList.add(getManager().getManagerPassword());
        validStrList.add(getManager().getManagerEmail());
        validStrList.add(getManager().getManagerRealName());
        if (CM.validAtLeastOneIsEmpty(validStrList))
        {
            info = "标有*的输入项都是必填项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Manager managerFromDB = managerDAO.findById(getManager().getManagerName());
        if (managerFromDB == null)
        {
            info = "没有找到此管理员。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        managerFromDB.setManagerPassword(getManager().getManagerPassword());
        managerFromDB.setManagerEmail(getManager().getManagerEmail());
        managerFromDB.setManagerRealName(getManager().getManagerRealName());
        managerFromDB.setManagerAddTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));

        Manager managerResult = managerDAO.save(managerFromDB);
        if (managerResult == null)
        {
            info = "管理员保存失败，请检查您的输入是否满足要求。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        List<ManagerModule> managerModuleNeedDeleteList = managerModuleDAO.getListByManagerName(managerResult.getManagerName());
        for (ManagerModule mmTemp : managerModuleNeedDeleteList)
        {
            int delResult = managerModuleDAO.delete(mmTemp);
            if (delResult != IResult.DELETE_SUCCESS)
            {
                info = "部分保存出错，请稍后再试。";
                json.put("success", false);
                json.put("info", info);
                return SUCCESS;
            }
        }

        String[] moduleNamesArray = getRequest().getParameterValues("moduleNamesArray");
        String[] moduleCheckedArray = getRequest().getParameterValues("moduleCheckedArray");

        List<ManagerModule> managerModuleListForSave = new ArrayList<ManagerModule>();
        Calendar cal = Calendar.getInstance();
        for (int i = 0; i < moduleCheckedArray.length; i++)
        {
            if (moduleCheckedArray[i].equals("1"))
            {
                ManagerModule managerModuleTemp = new ManagerModule();
                managerModuleTemp.setId(CM.getRandomTwentyFivePrimaryKeyId());
                managerModuleTemp.setManagerName(managerResult.getManagerName());
                managerModuleTemp.setModuleName(moduleNamesArray[i]);
                cal.add(Calendar.SECOND, 1);
                managerModuleTemp.setModuleAddTime(new Timestamp(cal.getTimeInMillis()));
                managerModuleListForSave.add(managerModuleTemp);
            }
        }

        List<ManagerModule> listResult = managerModuleDAO.saveList(managerModuleListForSave);

        json.put("success", true);
        return SUCCESS;
    }

    public String m_get_manager_module_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        Manager managerSession = (Manager) getSession().getAttribute("managerSession");

        List<ManagerModule> managerModuleListFromDB = managerModuleDAO.getListByManagerName(managerSession.getManagerName());
        json.put("moduleList", managerModuleListFromDB);
        json.put("success", true);
        return SUCCESS;
    }

    public String show_manager_info_list()
    {
        List<Manager> managerListFromDB = managerDAO.findAll();
        if (managerListFromDB == null || managerListFromDB.size() == 0)
        {
            setManagerViewList(null);
            return SUCCESS;
        }
        List<ManagerView> managerViewListTemp = new ArrayList<ManagerView>();
        for (Manager mTemp : managerListFromDB)
        {
            ManagerView managerViewTemp = new ManagerView();
            managerViewTemp.setManager(mTemp);
            managerViewTemp.setManagerModuleList(managerModuleDAO.getListByManagerName(mTemp.getManagerName()));
            managerViewListTemp.add(managerViewTemp);
        }
        setManagerViewList(managerViewListTemp);
        return SUCCESS;
    }

    public String shop_update_manager()
    {
        // 得到此商品的信息
        String manager_id_str = getRequest().getParameter("id");
        if (manager_id_str == null || CM.validIsEmpty(manager_id_str))
        {
            return ERROR;
        }
        Manager managerTemp = managerDAO.findById(manager_id_str);
        if (managerTemp == null)
        {
            setManager(null);
            setManagerModuleList(null);
            return SUCCESS;
        }

        setManager(managerTemp);
        setManagerModuleList(managerModuleDAO.getListByManagerName(managerTemp.getManagerName()));

        return SUCCESS;
    }

    public String m_delete_manager_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        if (CM.validIsEmpty(getCommonStr()))
        {
            info = "管理员用户名是必需项。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        Manager managerFromDB = managerDAO.findById(getCommonStr());
        if (managerFromDB == null)
        {
            info = "没有找到此管理员。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        List<ManagerModule> managerModuleListFromDB = managerModuleDAO.getListByManagerName(managerFromDB.getManagerName());
        if (managerModuleListFromDB != null)
        {
            for (ManagerModule mmTemp : managerModuleListFromDB)
            {
                int delResult = managerModuleDAO.delete(mmTemp);
                if (delResult != IResult.DELETE_SUCCESS)
                {
                    info = "删除时出现错误，请稍后重试。";
                    json.put("success", false);
                    json.put("info", info);
                    return SUCCESS;
                }
            }
        }
        int delResult = managerDAO.delete(managerFromDB);
        if (delResult != IResult.DELETE_SUCCESS)
        {
            info = "删除管理员失败。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }
        json.put("success", true);
        return SUCCESS;
    }

    public String m_update_province_postage_do()
    {
        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        String[] idsArray = getRequest().getParameterValues("ids");
        String[] postagesArray = getRequest().getParameterValues("postages");

        List<ProvincePostage> provincePostageListTemp = new ArrayList<ProvincePostage>();
        for (int i = 0; i < idsArray.length; i++)
        {
            ProvincePostage provincePostageFromDB = provincePostageDAO.findById(idsArray[i]);
            provincePostageFromDB.setProvincePostage(Double.parseDouble(postagesArray[i]));
            provincePostageListTemp.add(provincePostageFromDB);
        }

        List<ProvincePostage> ppResult = provincePostageDAO.saveList(provincePostageListTemp);
        if (ppResult == null)
        {
            info = "保存各省邮费失败，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String m_people_tenpay_declaration_do()
    {

        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        String temp_order_id = getRequest().getParameter("orderId");
        if (CM.validIsEmptyWithTrim(temp_order_id))
        {
            info = "没有找到此订单，请检查后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        ODAPI.do_tenpay_send(temp_order_id);

        json.put("success", true);
        return SUCCESS;
    }

    public String m_people_cancel_haiguan_declaration_do()
    {

        String method = getRequest().getMethod();
        System.out.println("=========请求是get还是post:" + method);
        if (method.toUpperCase().equals("GET"))
        {
            System.out.println("============如果直接输入网址进来的,什么操作都不做,必须是表单提交的!==========");
            return "404";
        }

        String temp_order_id = getRequest().getParameter("orderId");
        if (CM.validIsEmptyWithTrim(temp_order_id))
        {
            info = "没有找到此订单，请检查后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        boolean do_result = ODAPI.do_haiguan_cancel(temp_order_id);

        if (do_result == false)
        {
            info = "重新申报失败，请稍后重试。";
            json.put("success", false);
            json.put("info", info);
            return SUCCESS;
        }

        json.put("success", true);
        return SUCCESS;
    }

    public String getCommonStr()
    {
        return commonStr;
    }

    public void setCommonStr(String commonStr)
    {
        this.commonStr = commonStr;
    }

    public Map<String, Object> getJson()
    {
        return json;
    }

    public void setJson(Map<String, Object> json)
    {
        this.json = json;
    }

    public Manager getManager()
    {
        return manager;
    }

    public void setManager(Manager manager)
    {
        this.manager = manager;
    }

    public String getGoodsTypeJson()
    {
        return goodsTypeJson;
    }

    public void setGoodsTypeJson(String goodsTypeJson)
    {
        this.goodsTypeJson = goodsTypeJson;
    }

    public Goods getGoods()
    {
        return goods;
    }

    public void setGoods(Goods goods)
    {
        this.goods = goods;
    }

    public Map<String, GoodsType> getGoodsTypeMap()
    {
        return goodsTypeMap;
    }

    public void setGoodsTypeMap(Map<String, GoodsType> goodsTypeMap)
    {
        this.goodsTypeMap = goodsTypeMap;
    }

    public List<Goods> getGoodsList()
    {
        return goodsList;
    }

    public void setGoodsList(List<Goods> goodsList)
    {
        this.goodsList = goodsList;
    }

    public Page getPage()
    {
        return page;
    }

    public void setPage(Page page)
    {
        this.page = page;
    }

    public List<ComplexOrder> getComplexOrderList()
    {
        return complexOrderList;
    }

    public void setComplexOrderList(List<ComplexOrder> complexOrderList)
    {
        this.complexOrderList = complexOrderList;
    }

    public GoodsHistory getGoodsHistory()
    {
        return goodsHistory;
    }

    public void setGoodsHistory(GoodsHistory goodsHistory)
    {
        this.goodsHistory = goodsHistory;
    }

    public Order getOrder()
    {
        return order;
    }

    public void setOrder(Order order)
    {
        this.order = order;
    }

    public Comment getComment()
    {
        return comment;
    }

    public void setComment(Comment comment)
    {
        this.comment = comment;
    }

    public Shop getShop()
    {
        return shop;
    }

    public void setShop(Shop shop)
    {
        this.shop = shop;
    }

    public Coupon getCoupon()
    {
        return coupon;
    }

    public void setCoupon(Coupon coupon)
    {
        this.coupon = coupon;
    }

    public List<Coupon> getCouponList()
    {
        return couponList;
    }

    public void setCouponList(List<Coupon> couponList)
    {
        this.couponList = couponList;
    }

    public Article getArticle()
    {
        return article;
    }

    public void setArticle(Article article)
    {
        this.article = article;
    }

    public List<Article> getArticleList()
    {
        return articleList;
    }

    public void setArticleList(List<Article> articleList)
    {
        this.articleList = articleList;
    }

    public List<BuyerMessage> getBuyerMessageList()
    {
        return buyerMessageList;
    }

    public void setBuyerMessageList(List<BuyerMessage> buyerMessageList)
    {
        this.buyerMessageList = buyerMessageList;
    }

    public BuyerMessage getBuyerMessage()
    {
        return buyerMessage;
    }

    public void setBuyerMessage(BuyerMessage buyerMessage)
    {
        this.buyerMessage = buyerMessage;
    }

    public List<BuyerMessageView> getBuyerMessageViewList()
    {
        return buyerMessageViewList;
    }

    public void setBuyerMessageViewList(List<BuyerMessageView> buyerMessageViewList)
    {
        this.buyerMessageViewList = buyerMessageViewList;
    }

    public OrderReturn getOrderReturn()
    {
        return orderReturn;
    }

    public void setOrderReturn(OrderReturn orderReturn)
    {
        this.orderReturn = orderReturn;
    }

    public List<OrderReturn> getOrderReturnList()
    {
        return orderReturnList;
    }

    public void setOrderReturnList(List<OrderReturn> orderReturnList)
    {
        this.orderReturnList = orderReturnList;
    }

    public List<ComplexOrderReturn> getComplexOrderReturnList()
    {
        return complexOrderReturnList;
    }

    public void setComplexOrderReturnList(List<ComplexOrderReturn> complexOrderReturnList)
    {
        this.complexOrderReturnList = complexOrderReturnList;
    }

    public List<Buyer> getBuyerList()
    {
        return buyerList;
    }

    public void setBuyerList(List<Buyer> buyerList)
    {
        this.buyerList = buyerList;
    }

    public GoodsCommission getGoodsCommission()
    {
        return goodsCommission;
    }

    public void setGoodsCommission(GoodsCommission goodsCommission)
    {
        this.goodsCommission = goodsCommission;
    }

    public List<GoodsCommission> getGoodsCommissionList()
    {
        return goodsCommissionList;
    }

    public void setGoodsCommissionList(List<GoodsCommission> goodsCommissionList)
    {
        this.goodsCommissionList = goodsCommissionList;
    }

    public List<GoodsCommissionView> getGoodsCommissionViewList()
    {
        return goodsCommissionViewList;
    }

    public void setGoodsCommissionViewList(List<GoodsCommissionView> goodsCommissionViewList)
    {
        this.goodsCommissionViewList = goodsCommissionViewList;
    }

    public File getExcelFile()
    {
        return excelFile;
    }

    public void setExcelFile(File excelFile)
    {
        this.excelFile = excelFile;
    }

    public String getExcelFileFileName()
    {
        return excelFileFileName;
    }

    public void setExcelFileFileName(String excelFileFileName)
    {
        this.excelFileFileName = excelFileFileName;
    }

    public String getExcelFileContentType()
    {
        return excelFileContentType;
    }

    public void setExcelFileContentType(String excelFileContentType)
    {
        this.excelFileContentType = excelFileContentType;
    }

    public Kefu getKefu()
    {
        return kefu;
    }

    public void setKefu(Kefu kefu)
    {
        this.kefu = kefu;
    }

    public List<KefuView> getKefuViewList()
    {
        return kefuViewList;
    }

    public void setKefuViewList(List<KefuView> kefuViewList)
    {
        this.kefuViewList = kefuViewList;
    }

    public Buyer getBuyer()
    {
        return buyer;
    }

    public void setBuyer(Buyer buyer)
    {
        this.buyer = buyer;
    }

    public Advertisement getAdvertisement()
    {
        return advertisement;
    }

    public void setAdvertisement(Advertisement advertisement)
    {
        this.advertisement = advertisement;
    }

    public List<Advertisement> getAdvertisementList()
    {
        return advertisementList;
    }

    public void setAdvertisementList(List<Advertisement> advertisementList)
    {
        this.advertisementList = advertisementList;
    }

    public ManagerModule getManagerModule()
    {
        return managerModule;
    }

    public void setManagerModule(ManagerModule managerModule)
    {
        this.managerModule = managerModule;
    }

    public List<ManagerModule> getManagerModuleList()
    {
        return managerModuleList;
    }

    public void setManagerModuleList(List<ManagerModule> managerModuleList)
    {
        this.managerModuleList = managerModuleList;
    }

    public List<Manager> getManagerList()
    {
        return managerList;
    }

    public void setManagerList(List<Manager> managerList)
    {
        this.managerList = managerList;
    }

    public List<ManagerView> getManagerViewList()
    {
        return managerViewList;
    }

    public void setManagerViewList(List<ManagerView> managerViewList)
    {
        this.managerViewList = managerViewList;
    }

    public OrderDeclaration getOrderDeclaration()
    {
        return orderDeclaration;
    }

    public void setOrderDeclaration(OrderDeclaration orderDeclaration)
    {
        this.orderDeclaration = orderDeclaration;
    }

    public List<ProvincePostage> getProvincePostageList()
    {
        return provincePostageList;
    }

    public void setProvincePostageList(List<ProvincePostage> provincePostageList)
    {
        this.provincePostageList = provincePostageList;
    }

}
